<?php

    global $mikron;

    $mikron->Page->StartBody();

    if(isset($_GET['ajax']))
    {
        ob_clean();
    }

    // текущий активный кабинет
    $cabinet = $mikron->Site->auth->cabinet;
    $auth = $mikron->Site->auth;
    $cabinetamount = (int)$cabinet->amount->value;
    $chips = $mikron->Queries->Query('MARKET_ITEM', null, new Criterion('forsale', 1)); // фишки

    $mychips = Array();
    while($chip = $chips->fetch())
    {
        $code = $chip->code->value;
        $name = $chip->shortname->value;
        $count = $cabinet->$code->value;
        $class = $count==0?"chip0":"chip";
        $fontclass = $count==0?"disabledtext":null;
        $picture = $chip->picture->value;
        $filter = $count==0?"filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src='$picture', sizingMethod='scale');":null;
        $mychips[$code] = Array('code'=>$code, 'name'=>$name, 'class'=>$class, 'count'=>$count, 'fontclass'=>$fontclass, 'filter'=>$filter, 'picture'=>$picture);
    }
    $mikron->TemplateMaker->smarty->assign('cabinetamount', round($cabinetamount/100, 2));
    $mikron->TemplateMaker->smarty->assign('mychips', $mychips);

    ?>

    <h1>Баланс &ndash; {{$cabinetamount}} руб.</h1>
    <h1>Ваши шансы:<font color="#000">&nbsp;</font></h1>
    <table><tr>
    {{foreach from=$mychips key=k item=v}}
        <td align="center">
        <div class="{{$v.class}}">
        <div class="chip_{{$k}}" style="{{$v.filter}}">
        </div>
        </div>
        <font class="{{$v.fontclass}}">{{$v.name}}<br />{{$v.count}}шт</font></td>
    {{/foreach}}
    </tr></table>
    
<?php

    if(isset($_GET['ajax']))
    {
        $mikron->Page->EndBody(false);
        exit;
    }

?>